import cv2
from skimage.metrics import structural_similarity as compare_mse
from skimage.metrics import peak_signal_noise_ratio as compare_psnr
from skimage.metrics import mean_squared_error as compare_ssim
import matplotlib.pyplot as plt


# 1
img_origin = cv2.imread(r"C:\Users\Public\opencv\Figure\lena.jpg",0)
plt.subplot(421)
plt.imshow(img_origin)

img_Mb = cv2.imread(r'C:\Users\Public\opencv\Figure\lenaMb.jpg',0)
plt.subplot(422)
plt.imshow(img_Mb)

img_inv = cv2.imread(r'C:\Users\Public\opencv\Figure\lenaInv.jpg',0)
plt.subplot(423)
plt.imshow(img_inv)

img_invn = cv2.imread(r'C:\Users\Public\opencv\Figure\lenaInvn.jpg',0)
plt.subplot(424)
plt.imshow(img_invn)

### 原图与运动模糊后的逆滤波图像之间的评价参数
mse = compare_mse(img_origin,img_inv)
print('MSE:{}'.format(mse))
psnr = compare_psnr(img_origin,img_inv)
print('PSNR:{}'.format(psnr))
ssim = compare_ssim(img_origin,img_inv)
print('SSIM:{}'.format(ssim))

# 原图与运动模糊+噪声后的逆滤波图像之间的评价参数
mse = compare_mse(img_origin,img_invn)
print('MSE:{}'.format(mse))
psnr = compare_psnr(img_origin,img_invn)
print('PSNR:{}'.format(psnr))
ssim = compare_ssim(img_origin,img_invn)
print('SSIM:{}'.format(ssim))


# 2
img_origin = cv2.imread(r"C:\Users\Public\opencv\Figure\lena.jpg",0)
plt.subplot(425)
plt.imshow(img_origin)

img_Mb = cv2.imread(r'C:\Users\Public\opencv\Figure\lenaMb.jpg',0)
plt.subplot(426)
plt.imshow(img_Mb)

img_wd = cv2.imread(r"C:\Users\Public\opencv\Figure\lenaMd.jpg",0)
plt.subplot(427)
plt.imshow(img_wd)

img_wdn = cv2.imread(r"C:\Users\Public\opencv\Figure\lenaWdn.jpg",0)
plt.subplot(428)
plt.imshow(img_wdn)

# 原图与运动模糊后的维纳滤波图像之间的评价参数
mse = compare_mse(img_origin,img_wd)
print('MSE:{}'.format(mse))
psnr = compare_psnr(img_origin,img_wd)
print('PSNR:{}'.format(psnr))
ssim = compare_ssim(img_origin,img_wd)
print('SSIM:{}'.format(ssim))
# 原图与运动模糊+噪声后的维纳滤波图像之间的评价参数
mse = compare_mse(img_origin,img_wdn)
print('MSE:{}'.format(mse))
psnr = compare_psnr(img_origin,img_wdn)
print('PSNR:{}'.format(psnr))
ssim = compare_ssim(img_origin,img_wdn)
print('SSIM:{}'.format(ssim))
cv2.waitKey(0)
cv2.destroyAllWindows()

